:strlen0.3  StrVar  [RtnVar]
  setlocal EnableDelayedExpansion
  set "s=#!%~1!"
  set "len=0"
  for %%A in ( 6561 2187 729 243 81 27 9 3 1) do (
    set /A mod=2*%%A
    for %%Z in (!mod!) do (
        if !mod! GTR 8190 (
		set mod=8190
	)
	if "!s:~%%Z,1!" neq "" (
        set /a "len+=%%Z"
        set "s=!s:~%%Z!"

        ) else (
            if "!s:~%%A,1!" neq "" (
                set /a "len+=%%A"
                set "s=!s:~%%A!"
            )
        )
    )
  )
